package cn.edu.sdjzu.xg2103.service;

import cn.edu.sdjzu.xg2103.controller.helper.JdbcHelper;
import cn.edu.sdjzu.xg2103.controller.security.TeacherServiceInterface;
import cn.edu.sdjzu.xg2103.dao.TeacherDao;
import cn.edu.sdjzu.xg2103.entity.Pagination;
import cn.edu.sdjzu.xg2103.entity.Teacher;
import cn.edu.sdjzu.xg2103.exception.BysjException;
import cn.edu.sdjzu.xg2103.entity.Condition;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
//import java.util.concurrent.locks.Condition;

public class TeacherService {
    public static final TeacherDao teacherDao = TeacherDao.getInstance();
    private static  TeacherService teacherService = new TeacherService();
    private TeacherService(){}
    public static TeacherService getInstance() {
        return teacherService;
    }
    public boolean update(Teacher teacher)throws SQLException , BysjException {
        Connection connection = JdbcHelper.getConn();
        boolean updated = teacherDao.update(connection,teacher);
        JdbcHelper.close(connection);
        return updated;
    }



    public Collection<Teacher> findAll(List<Condition> conditionslist, Pagination pagination) throws SQLException {
        Connection connection = JdbcHelper.getConn();
        Collection<Teacher> teachers = teacherDao.findAll(connection,conditionslist,pagination);
        return teachers;
    }
}
